import moment from 'moment';

import { Divider } from 'antd';

import _usersApply from './users/apply/columns';
import _goods from './goods/columns';
import _goodsHome from './goods/home/columns';
import _goodsHomeAdd from './goods/home/addcolumns';
import _profileStep2 from './profile/step2Columns';
import _profileStep3 from './profile/step3Columns';
import _users from './users/columns';
import _userGoods from './users/goods/columns';
import _userIntegrals from './users/integrals/columns';
import _bannersCenter from './banners/centerColumns';
import _questions from './questions/columns';
import _feedbacks from './feedbacks/columns';

const randerOpenId = (_, { type = 0, openId }) => (<p style={{whiteSpace: 'nowrap', color: type === 0 ? '#52c41a' : type === 1 ? '#f5222d' : type === 2 ? '#1890ff' : '#cf0' }}>{openId}</p>);
const renderTime = text => (<span style={{whiteSpace: 'nowrap'}}>{text}</span>);
const _id = [{ title: '序号', dataIndex: 'id', sorter: true, align: 'center', width: 75 }];
const _openId = [{ title: 'OPENID', dataIndex: 'openId', align: 'center', render: randerOpenId }];
const _goodsName = [{
  title: '奖品名称',
  dataIndex: 'GoodsPrizes',
  width: '50%',
  render: record => Array.isArray(record) && record.map(item => (
    <span key={item.id}>
      {item.title}
      <Divider dashed style={{margin: 0}} />
    </span>
  )),
}];
const _time = [{ title: '创建日期', dataIndex: 'createdAt', sorter: true, align: 'center', render: renderTime }, { title: '更新日期', dataIndex: 'updatedAt', sorter: true, align: 'center', render: renderTime }];

const usersApply = _id.concat(_openId, _usersApply, _time);
const goods = _id.concat(_goodsName, _goods, _time);
const goodsHome = _id.concat(_goodsName, _goodsHome, _time);
const goodsHomeAdd = _id.concat(_goodsName, _goodsHomeAdd, _time);
const profileStep2 = _id.concat(_profileStep2, _time);
const profileStep3 = _id.concat(_profileStep3, _time);
const users = _id.concat(_openId, _users, _time);
const userGoods = _id.concat(_userGoods, _time);
const userIntegrals = _id.concat(_userIntegrals, _time);
const bannersCenter = _id.concat(_bannersCenter, _time);
const questions = _id.concat(_questions, _time);
const feedbacks = _id.concat(_openId, _feedbacks, _time);

export {
  usersApply,
  goodsHome,
  goods,
  goodsHomeAdd,
  profileStep2,
  profileStep3,
  users,
  userGoods,
  userIntegrals,
  bannersCenter,
  questions,
  feedbacks,
}